package com.ms.pda

import android.view.Gravity
import com.blankj.utilcode.util.LogUtils
import com.blankj.utilcode.util.ToastUtils
import com.blankj.utilcode.util.Utils
import com.ms.architecture.base.BaseApplication
import com.ms.pda.model.Constants
import com.ms.pda.net.Request
import me.jessyan.autosize.AutoSizeConfig
import me.jessyan.autosize.unit.Subunits
import okhttp3.OkHttpClient
import rxhttp.RxHttpPlugins

class MainApp : BaseApplication() {

    override fun onCreate() {
        super.onCreate()
        adapterInit()
        utilsInit()
        networkInit()
    }

    /**
     * 工具初始化
     */
    private fun utilsInit() {
        Request.init()
        Utils.init(this)
        ToastUtils.getDefaultMaker().setGravity(Gravity.CENTER, 0, 0)
        LogUtils.getConfig().isLogSwitch = Constants.DEBUG
    }

    /**
     * 适配框架初始化
     */
    private fun adapterInit() {
        AutoSizeConfig.getInstance().unitsManager
            .setSupportDP(false)
            .setSupportSP(false).supportSubunits = Subunits.PT
    }

    /**
     * 网络请求初始化
     */
    private fun networkInit() {
        RxHttpPlugins.init(OkHttpClient()).setDebug(Constants.DEBUG)
    }

}